var pos : Vector2 = new Vector2(850,400);
var size : Vector2 = new Vector2(120,50);
var bullet : Texture2D;
var gunScript : GunwithReloadandFirerate;

private var bulletWidth : int = 12;
private var bulletX : int = 0;

function Start(){
    var gameobject = GameObject.Find("Player");
    // (ScriptName is the name of the javascript file)
    gunScript = gameobject.GetComponentInChildren  (GunwithReloadandFirerate);
}

function OnGUI()
{
  var oldMatrix : Matrix4x4;
  var tMatrix : Matrix4x4;
  var width : int = 1016; //Reference resolution
  var height : int = 496; //Reference resolution

  oldMatrix = GUI.matrix; //Store current matrix
  tMatrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3(1.0*Screen.width/width, 1.0*Screen.height/height, 1.0)); //Construct matrix to scale to actual view size
  GUI.matrix = tMatrix; //Set the GUI matrix to the scaling matrix
  // draw the background:
  GUI.BeginGroup (new Rect (pos.x, pos.y, size.x, size.y));
  
  for(var i = 0; i< gunScript.GetBullets(); i++){
    GUI.DrawTexture(Rect(bulletX,0,12,50), bullet, ScaleMode.StretchToFill, true, 4.3f);
    bulletX += bulletWidth;
    //GUI.DrawTexture(Rect(bulletX+12,0,12,50), bullet, ScaleMode.StretchToFill, true, 4.3f);
  }
  bulletX = 0;
  GUI.EndGroup ();

  GUI.matrix = oldMatrix; //Set the original matrix back
} 
